<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>while语句</title>
	</head>

	<body>
		<script>
			var a = alert("老师讲解内容");
			var answer = prompt("大家都会了吗？（y/n）");
			var count = 1;
			while(answer == 'n' && count <= 2) {
				alert("老师再讲解一遍");
				answer = prompt("大家会了吗？（y/n）");
				count++;
			}
			alert("放学");
		</script>
	</body>

</html>